<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑组织机构信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" id="return-btn" onclick="returnIndex()"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回
              </button>
            <button class="btn btn-info" id="save" onclick="SecurityOrgMgr.submitForm()" type="button"><i
                    class="fa fa-save">&nbsp;&nbsp;</i>保存
            </button>
        </div>
        </form>
      </div>

      <div class="form-horizontal  h-form-warp">
        <div class="h-msg-title h-table-header">
          <strong>组织机构表信息</strong>
        </div>
        <form action="/securityOrg/saveSecurityOrg" class="form-horizontal" id="securityOrgForm" method="post"
              role="form">
          <input id="operation" name="operation" type="hidden" value="${operation!}"/>
          <input class="form-control" id="orgId" name="orgId" type="hidden" value="${securityOrg.orgId!}">
          <input class="form-control" id="orgParentId" name="orgParentId" type="hidden"
                 value="${securityOrg.orgParentId!}">
          <div class="form-group">
            <label class="col-sm-2 control-label">上级机构：</label>
            <div class="col-sm-8">
              <input class="form-control" id="orgParentName" name="orgParentName" readonly="readonly"
                     required="required"
                     type="text" value="${securityOrg.orgParentName!}"/>
            </div>
            <div class="col-sm-1">
              <input class="btn btn-info" id="selectParentOrg" onclick="SecurityOrgMgr.selectParentOrg()" type="button"
                     value="选择"/>
            </div>
            <div class="col-sm-1">
              <label class="required">*</label>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">机构编码：</label>
            <div class="col-sm-8">
              <input class="form-control" id="orgCode" name="orgCode" required="required" type="text"
                     value="${securityOrg.orgCode!}"/>
            </div>
            <div class="col-sm-1">
              <span class="required">*</span>
            </div>
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">机构名称：</label>
            <div class="col-sm-8">
              <input class="form-control" id="orgName" name="orgName" required="required" type="text"
                     value="${securityOrg.orgName!}"/>
            </div>
            <div class="col-sm-1">
              <span class="required">*</span>
            </div>
          </div>
          <div class="form-group">
            <@PageDict dict_name="orgType" dict_desc="机构类型" dict_key="org_type" dict_value="${securityOrg.orgType!}"
            dict_type="select" label_class="col-sm-2 control-label text-right" dict_class="col-sm-8" required="required"
            />
          </div>
          <div class="form-group">
            <label class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-8">
              <input class="form-control" id="orgComment" name="orgComment" required="required"
                     type="text"
                     value="${securityOrg.orgComment!}"/>
            </div>
            <div class="col-sm-1">
              <span class="required">*</span>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
  <!-- end: PAGE -->
</div>
<!-- end: MAIN CONTAINER -->
</div>

<#include "/common/jslib.html">
<!-- 弹窗下拉 -->
<script type="text/javascript">
    function returnIndex() {
        window.location.href = "/securityOrg/query";
    }

    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        // 弹出窗体控制
        SecurityOrgMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                }
                initDict(DICTURL, FORM, operation);
            },
            // init end

            // 提交数据
            submitForm: function () {
                Jmts.ajaxSubmit(document.getElementById("securityOrgForm"), function (result) {
                    if (result.success) {
                        if (operation == 'add') {
                            window.parent.location.reload();
                        } else {
                            Jmts.succTips(result.msg);
                            window.parent.location.reload();
                        }
                    } else {
                        Jmts.warnTips(result.msg);
                    }
                });
                return false;
            },
            // submitForm end
            returnIndex: function () {
                window.location.href = "/securityOrg/query";
            },
            selectParentOrg: function () {
                var url = "/securityOrg/to-selectParentOrg?selectType=single&returnMethod=SecurityOrgMgr.initParentOrg";
                Jmts.openDialog("parentOrg", url, "选择上级组织机构", 500, 800, 32);
            },
            initParentOrg: function (selectStr) {
                var orgs = selectStr.split("#");
                var orgParentId = orgs[0];
                var orgParentName = orgs[1];
                $("#orgParentId").val(orgParentId);
                $("#orgParentName").val(orgParentName);
            }
        };
        // 执行初始化
        SecurityOrgMgr.init();
        // 前台验证表单
        $("#securityOrgForm").validate();
    });
</script>
</body>
</html>
